package logic

import (
	"context"
	"video/mysql/model"

	"video/videorpc/internal/svc"
	"video/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCommentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentListLogic {
	return &CommentListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 评论列表
func (l *CommentListLogic) CommentList(in *videorpc.CommentListRequest) (*videorpc.CommentListResponse, error) {
	// todo: add your logic here and delete this line

	var comment model.Comment
	var list []*videorpc.CommentList
	commentList, err := comment.CommentList(model.DB, list, in)
	if err != nil {
		return nil, err
	}

	return &videorpc.CommentListResponse{
		List: commentList,
	}, nil
}
